package com.qf.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.qf.mapper.DtsPermissionMapper;
import com.qf.pojo.DtsPermission;
import com.qf.service.PermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;


@Service
public class PermissionServiceImpl implements PermissionService {

    @Autowired
    private DtsPermissionMapper dtsPermissionMapper;

    @Override
    public Set<String> queryByRoleIds(Integer[] roleIds) {

        QueryWrapper wrapper = new QueryWrapper();
        wrapper.in("role_id", Arrays.asList(roleIds));
        wrapper.eq("deleted", false);

        HashSet<String> hashSet = new HashSet<>();
        List<DtsPermission> list = dtsPermissionMapper.selectList(wrapper);
        for (DtsPermission dtsPermission : list) {
            hashSet.add(dtsPermission.getPermission());
        }

        return hashSet;
    }
}
